export default function({$axios,redirect,route,store}){

  //基本配置

  $axios.defaults.timeout=10000;

  //请求拦截
  $axios.onRequest(config=>{
    // console.log('请求拦截')

    config.headers.token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFsZXgiLCJfaWQiOiI1ZThhMGQ2MzczNDg2MDIzYTRmZDY4ZGYiLCJpYXQiOjE1ODY2MDIwODcsImV4cCI6MTU4NjY4ODQ4N30.bgzJALn6DiKMQuhohPjjml3cgjZbtXiU2Kfg9t1lcGo';

    return config;

  })

  //响应拦截
  $axios.onResponse(res=>{
    // console.log('响应拦截')
    
    if(res.data.err === 2 && route.fullPath !== '/login'){
      redirect('/login?path='+route.fullPath)
    }

    return res
  })

  //错误处理
  $axios.onError(error=>{
    //处理
    return error;
  })


}